<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        li {
            list-style: none;
        }
        
        .ul {
            display: flex;
            line-height: 40px;
        }
        
        .more,
        .ul li {
            height: 40px;
            border: 1px solid #d4d4d4;
            line-height: 40px;
            padding: 0 8px;
            cursor: pointer;
        }
        
        .ul li {
            border-right: none;
        }
        
        .more {
            padding-left: 50px;
        }
        
        .more a {
            display: block;
            text-decoration: none;
            color: #999;
        }
        
        .more:hover a {
            transform: scale(1.1);
            text-decoration: underline;
        }
        
        .header {
            color: #999;
            display: flex;
            font-size: 11px;
            height: 40px;
            width: 326px;
            margin: 0 auto;
            margin-top: 60px;
            justify-content: space-between;
        }
        
        .content {
            width: 326px;
            margin: 0 auto;
            border: 1px solid #d4d4d4;
            box-sizing: border-box;
            padding: 20px 15px;
            border-top: none;
        }
        
        .div2 img {
            width: 140px;
        }
        
        .div {
            display: flex;
            justify-content: space-between;
            font-size: 11px;
        }
        
        .div3 span {
            color: #999;
            font-size: 8px;
        }
        
        .show {
            display: none;
        }
    </style>

</head>

<body>
    <div class="header">
        <ul class="ul">
            <li index="0">千峰课堂</li>
            <li index="1">HTML5课堂</li>
            <li index="2">JS开发课程</li>
        </ul>
        <div class="more"> <a href="http://baidu.com"> >>更多</a> </div>
    </div>
    <div class="content">
        <div class="div">
            <div class="div2"><img src="img/pic_bg.jpg" alt=""></div>
            <div class="div3">
                <p>HTML5开课典礼仪式</p><span>点击：500 2020.07.20</span>
                <p>HTML5开课典礼仪式</p><span>点击：500 2020.07.20</span>

            </div>
        </div>
        <div class="div show">
            <div class="div2"><img src="img/pic_bg.jpg" alt=""></div>
            <div class="div3">
                <p>JS开发课程</p><span>点击：100 2020.07.20</span>
                <p>JS开发课程</p><span>点击: 400 2020.07.20</span>

            </div>
        </div>
        <div class="div show">
            <div class="div2"><img src="img/pic_bg.jpg" alt=""></div>
            <div class="div3">
                <p>小小课堂</p><span>点击：800 2020.07.20</span>
                <p>小小课堂</p><span>点击：654 2020.02.20</span>

            </div>
        </div>
    </div>
    <script>
        // let liList = document.querySelectorAll('li');
        // let divList = document.querySelectorAll('.div');
        // for (let i = 0; i < liList.length; i++) {
        //     liList[i].onclick = function() {
        //         console.log(1)
        //         for (let n = 0; n < divList.length; n++) {
        //             console.log(n)
        //             divList[n].className = 'div show'
        //             divList[i].className = 'div'
        //         }
        //     }
        // }
    </script>
    <script src="jquery.min.js"></script>
    <script>
        $('li').click(function() {
            let i = this.getAttribute('index')
            for (let n = 0; n < $('.div').length; n++) {
                $('.div').eq(n).addClass('show')
            }
            $('.div').eq(i).toggleClass('show')
        })
    </script>
</body>

</html>